const GeoIpLite = require("geoip-lite")

module.exports = (req, res, next) => {
  const ipAddress = req.headers["x-forwarded-for"] || req.connection.remoteAddress
  console.log('ipAddress---',ipAddress);

  const locationInfo = GeoIpLite.lookup('192.168.1.3')
  
  res.ipAddress = ipAddress
  
  res.locationInfo = locationInfo || "未知"

  next()
}
